<?php
$this->lang->load('template');
$this->load->view('admin/common/header',array('_user'=>$_user,'modules'=>$modules,'pageTitle'=>'评论管理'));
$setting = array(
	'attr' => array(
		'class' => 'index'
	),
	'fields' => array(
		'id' => array('label'=> $this->lang->line('tpl_id')),
		'username' => array('label' => $this->lang->line('tpl_username')),
		'type'	=> array('label'=> $this->lang->line('tpl_type')),
		'content' => array('label' => $this->lang->line('tpl_content')),
		//'status' => array('label' => $this->lang->line('tpl_status'),'filter'=>'__doFilter','is_sort'=>true ),
		//'sorts' => array('label' => $this->lang->line('tpl_sorts'),'is_sort'=>true ),
		'action'	=> array('label' => $this->lang->line('tpl_actions'),'filter'=>'__doFilter' ),
	),
	'data' => isset($result['result']) ? $result['result'] : null,
);

function __doFilter($f,$r){
	$str = isset($r[$f])?$r[$f]:'';
	//$commentType = array('article'=>'文本', 'image'=>'图片', 'flash'=>'flash');
	//$str = $mediaType[$str];
	if($f=='action'){
		$str .= '<a href="'.site_url('admin/comments/remove/'.$r['id']).'" class="remove_link" rel="'.$r['id'].'" title="删除"><img alt="Delete" src="'.base_url('images/admin/icons/delete.png').'" /></a>';
	}
	$str = empty($str) ? '&nbsp;&nbsp;':$str;
	return $str;
}
?>
<style>
.tr span {
	clear:both;
	display:block;
	color:#999
}
</style>
<script language="javascript">
$(document).ready(function(){
	$('.remove_link').click(
		function(event){
			event.preventDefault();
			url = this.href+'?format=json';
			return Admin.remove(
				url,
				'您确定删除该数据吗？'
			);
		}
	);
	$('.sort_link').click(
		function(event){
			event.preventDefault();
			field = this.attributes['field'].value;;
			return urlRequest.setSort(field);
		}
	);
});

</script>
<div class="clear tile_bg" id="content">
  <div class='toolbar'>
    <ul class='actions'>
    </ul>
    <br class='clear' />
  </div>
  <h1>
  评论列表 </h1>
  <div id="new-item"></div>
  <?=htmlTable($setting);?>
  <?php 
  	if (isset($result['pager'])) :
  ?>
  <div id="pagination" class="pagination"> 
  	<?php
  		echo $result['pager']->create_links();
  	?>
  </div>
  <?php endif;?>
  <br class='clear' />
</div>
</div>
<?php $this->load->view('admin/common/footer');?>